-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Linux DRM backend #69
base: main
Are you sure you want to change the base?
Conversation
What compatibility risks exist when using DRM legacy interfaces with newer Linux kernels? Could you verify the compatibility status of libdrm across different kernel versions? What prevents the DRM backend from rendering content across the full screen resolution? |
@a1091150, You might check DRM backend for your environment as well. |
|
||
return true; | ||
|
||
bail_crtc: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused about this. It should be as below.
/* Retrieve resources */
if (!get_resources(tx->drm_dri_fd, &RES(tx)))
goto bail_res;
....
bail_fb:
drmModeRmFB(tx->drm_dri_fd, tx->fb_id);
munmap(tx->fb_base, tx->fb_len);
bail_crtc:
drmModeFreeCrtc(CRTC(tx));
bail_conn:
drmModeFreeConnector(CONN(tx));
bail_res:
drmModeFreeResources(RES(tx));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebase the latest main
branch and resolve conflicts.
Implemented DRM-based framebuffer setup, including: - Opening DRM device - Creating dumb buffers and mapping them to framebuffers - Setting mode and handling CRTC for connected display output Currently, using the DRM legacy interface is suitable for Mado's backend if we only need basic window display without advanced features. The DRM legacy is simpler to implement. Close sysprog21#60
@@ -83,6 +83,9 @@ For SDL backend, install the [SDL2 library](https://www.libsdl.org/). | |||
* macOS: `brew install sdl2` | |||
* Ubuntu Linux / Debian: `sudo apt install libsdl2-dev` | |||
|
|||
For DRM backend, install the [libdrm](https://cgit.freedesktop.org/mesa/drm/). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the hyperlink to https://gitlab.freedesktop.org/mesa/drm
@@ -0,0 +1,24 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decouple linux VT changes in another pull request which adapts fbdev backend as well. That is, the linux VT routines should be shared between fbdev and DRM backends.
I need more time to research and adjust. |
return false; | ||
} | ||
|
||
/* Virtual terminal part is same as fbdev */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decouple this to another pull request to share the Linux VT manipulation.
{ | ||
*resources = drmModeGetResources(fd); | ||
if (*resources == NULL) { | ||
log_error("drmModeGetResources failed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make the error messages consistent, starting with "Failed to ..."
@@ -12,6 +12,10 @@ config BACKEND_FBDEV | |||
bool "Linux framebuffer support" | |||
select CURSOR | |||
|
|||
config BACKEND_DRM | |||
bool "DRM support" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider changing to Linux DRM support
for avoiding confusion.
uint32_t fb_id; | ||
uint32_t *fb_base; | ||
size_t fb_len; | ||
// int display_width; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave no dead code.
twin_coord_t width = right - left; | ||
int line_length = 4 * tx->width; | ||
off_t off = line_length * top + 4 * left; | ||
unsigned char *dest = (unsigned char *) tx->fb_base + off; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace unsigned char
with uint8_t
for consistency and use uintptr_t
for pointer arithmetic. That is:
uint8_t *dest = (uint8_t *)((uintptr_t) tx->fb_base + off);
return NULL; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove one empty line here.
free(ctx->priv); | ||
free(ctx); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
Check the DRM implementation for reference: https://github.com/zlgopen/awtk-linux-fb/blob/master/awtk-port/lcd_linux/lcd_linux_drm.c |
Currently, using the DRM legacy interface is suitable for Mado's backend because we only need basic window display without advanced features.